package org.fangzz.cameramgr.cameramonitor.dto;

import org.fangzz.cameramgr.cameramonitor.model.DisplayResolution;
import org.fangzz.cameramgr.cameramonitor.model.Store;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class StoreSummary {

    private Integer id;

    private String storeName;

    private String address;

    private String bossName;

    private String bossPhone;

    private String areaCode;

    private Integer maxTranscodeThread;

    private List<DisplayResolutionSummary> resolutions;


    public static StoreSummary convert(Store store){
        StoreSummary storeSummary = new StoreSummary();
        BeanUtils.copyProperties(store,storeSummary);
        storeSummary.resolutions = DisplayResolutionSummary.convert(store.getResolutions());
        return  storeSummary;
    }

    public static List<StoreSummary> convert(List<Store> storeList){
        List<StoreSummary> storeSummaries = new ArrayList<>();
        storeList.stream().forEach(Store->{
            storeSummaries.add(StoreSummary.convert(Store));
        });
        return storeSummaries;
    }

    public static Page<StoreSummary> convert(Page<Store> storePage){
        Page<StoreSummary> storeSummaryPage = new PageImpl<>(StoreSummary.convert(storePage.getContent()),storePage.getPageable(),storePage.getTotalElements());
        return storeSummaryPage;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getBossName() {
        return bossName;
    }

    public void setBossName(String bossName) {
        this.bossName = bossName;
    }

    public String getBossPhone() {
        return bossPhone;
    }

    public void setBossPhone(String bossPhone) {
        this.bossPhone = bossPhone;
    }

    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }

    public Integer getMaxTranscodeThread() {
        return maxTranscodeThread;
    }

    public void setMaxTranscodeThread(Integer maxTranscodeThread) {
        this.maxTranscodeThread = maxTranscodeThread;
    }

    public List<DisplayResolutionSummary> getResolutions() {
        return resolutions;
    }

    public void setResolutions(List<DisplayResolutionSummary> resolutions) {
        this.resolutions = resolutions;
    }
}
